﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;

namespace Grid.Extensions
{
    public class DataGridViewNumericCell : DataGridViewTextBoxCell
    {
        public DataGridViewNumericCell() : base()
        {
        }

        public override void InitializeEditingControl(int rowIndex, object 
            initialFormattedValue, DataGridViewCellStyle dataGridViewCellStyle)
        {
            base.InitializeEditingControl(rowIndex, initialFormattedValue, dataGridViewCellStyle);
            DataGridViewNumericUpDownControl ctl = DataGridView.EditingControl as DataGridViewNumericUpDownControl;
            DataGridViewNumericColumn column = (DataGridViewNumericColumn)this.OwningColumn;
            ctl.Minimum = column.MinValue;
            ctl.Maximum = column.MaxValue;
            ctl.Value = (int)this.Value;
        }

        public override Type EditType
        {
            get
            {
                return typeof(DataGridViewNumericUpDownControl);
            }
        }

        public override Type ValueType
        {
            get
            {
                return typeof(int);
            }
        }

        public override object DefaultNewRowValue
        {
            get
            {
                return 0;
            }
        }

    }
}
